home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / QuakeTools / src / libqtools / crc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-11  |  698 b   |  25 lines

  1. #ifndef    CRC_H
  2. #define    CRC_H
  3.  
  4. #define CRC_INIT_VALUE    0xffff
  5. #define CRC_XOR_VALUE    0x0000
  6.  
  7. extern unsigned short int crctable[256];
  8.  
  9. static void CRC_Init(unsigned short int *crcvalue);
  10. static void CRC_ProcessByte(unsigned short int *crcvalue, unsigned char data);
  11. static unsigned short int CRC_Value(unsigned short int crcvalue);
  12.  
  13. static inline void CRC_Init(unsigned short int *crcvalue) {
  14.   *crcvalue = CRC_INIT_VALUE;
  15. }
  16.  
  17. static inline void CRC_ProcessByte(unsigned short int *crcvalue, unsigned char data) {
  18.   *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
  19. }
  20.  
  21. static inline unsigned short int CRC_Value(unsigned short int crcvalue) {
  22.   return crcvalue ^ CRC_XOR_VALUE;
  23. }
  24. #endif
  25.